<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>博客日历</title>
<style type="text/css">
* {
	margin:0;
	padding:0;
	font:10px tahoma;
}
.table {
	text-align:center;
	width:200px;
	font-size:10px;
	/*color: #27B0C1;*/
border-top:1px solid #EEEEEE;
	border-left:1px solid #EEEEEE;
}
.table td {
	border-bottom:1px solid #EEEEEE;
	border-right:1px solid #EEEEEE;
	width:21px;
	height:20px;
	line-height:16px;
	color:#666666;
}
</style>
<!-- 主要通js来输出日历 以后可做成js插件 作者宋占涛-->
<script type="text/javascript">


//创建表
function  myCalendar ()
{
	var now_date=new Date();
	//本月第一天是星期几
	var fistdayDate=new Date(now_date.getYear(),now_date.getMonth(),1);
	var fistDay=fistdayDate.getDay();
	var nowMonth=now_date.getMonth();
	var  arr=['周一','周二','周三','周四','周五','周六','周日'];
	//定义一三五七八十蜡31天永不差
	//定义每月天数数组
	var days = ["31","28","31","30","31","30","31","31","30","31","30","31"]
	//闰年29天
	if (((now_date % 4 == 0) && (now_date % 100 != 0)) || (now_date % 400 == 0)) days[1] = "29";
	
	
	
	var t=document.createElement('table');
	

	var  _tableTile =	t.createCaption();
	_tableTile.innerHTML=now_date.getYear()+"-"+now_date.getDate();
    t.className='table';
	t.cellPadding=0;
	t.cellSpacing=0;


	var thead=t.insertRow();
	
	for(var i=0;i<7;i++)
	{
	
	 var c =thead.insertCell();
	 c.innerHTML=arr[i];
	}
	
	
	//var  rq=new Date();
	
	var day=1;
	var  point=1;
	for(var i=0;i<6;i++)
	{
	var r =	t.insertRow();
		
		for(var k=0;k<7;k++)
		{
			
			var c =r.insertCell();
			
	
			
			//是否超出本月最大天数
			if(day<=days[nowMonth]&&point>=fistDay)
			{
				
				c.innerHTML=now_date.getDate()==day?"<strong style='color:red;'>"+(day++)+"</strong>":day++;
		
		
				
			}else
			{
				c.innerHTML="&nbsp;";
				
			}
			point++;
			
		
		
		
			
		}
		
	}
	

	document.getElementById("rl").appendChild(t);
	
	
		
}

window.onload=function (){
myCalendar ();


	
}



</script>
</head>
<body >
<div id="rl"></div>
</body>
</html>
